function content() {
    let time1 = new Date("2023-11-11 00:00:00");
    let time2 = new Date();
    let time = time1.getTime() - time2.getTime();

    let day = time / (1000 * 60 * 60 * 24);

    // 向下取整
    day = Math.floor(day);

    let dHour = time - day * (1000 * 60 * 60 * 24);
    let hour = dHour / (1000 * 60 * 60);
    hour = Math.floor(hour);
    // console.log(hour);

    let dMin = dHour - hour * (1000 * 60 * 60);
    let minutes = dMin / (1000 * 60)
    minutes = Math.floor(minutes);
    // console.log(minutes);

    let dSec = dMin - 1000 * 60 * minutes;
    let seconds = Math.floor(dSec / 1000);
    // console.log(seconds);

    let res = `距离双十一还有<br>${day}天${hour}时${minutes}分${seconds}秒`;
    box.innerHTML = res;
}

function color(fc = 1, bc = 1) {
    function randomColor(op = 1) {
        function rgb() {
            return Math.floor(Math.random() * 256)
        }
        return `rgba(${rgb()},${rgb()},${rgb()},${op})`;
    }
    let res = randomColor(bc);
    let res2 = randomColor(fc);

    // console.log(res);
    document.body.style.backgroundColor = res;
    box.style.color = res2;
}

function position() {
    let l = Math.floor(Math.random() * 100);
    let t = Math.floor(Math.random() * 100);

    console.log("left："+l, "top："+t);

    box.style.left = `${l}%`;
    box.style.top = `${t}%`;
}

setInterval(function () {
    content();
    color(1, 0.2);
    position();
}, 1000)


// let arr = ['a', 'b', 'a', 'b', 'b', 'c'];

// 第一种
/* let newArr = [];
arr.forEach(function(item){
    let i =  newArr.indexOf(item);
    if(i == -1) newArr.push(item);
})
console.log(newArr); // ['a', 'b', 'c'] */

// 第二种
/* let newArr = arr.sort();
newArr.forEach(function(item,index){
    let i =  newArr.indexOf(item);
    let res =  newArr.indexOf(item, i + 1);
    if(res != -1){
        newArr.splice(index,index + 1)
    }
    
})
console.log(newArr); // ['a', 'b', 'c'] */

// 第三种
/* let res = arr.filter(function(item, index){
    return arr.indexOf(item) === index;
})
console.log(res); */


/* let arr = ["特等奖", "一等奖", "二等奖", "三等奖", "四等奖", "安慰奖"];
let newArr = [];

function fn(x){
    function rd(){
        return Math.floor(Math.random() * x.length);
    }

    while(newArr.length < x.length){
        let n =  rd();
        if(newArr.indexOf(x[n]) == -1){
            newArr.push(x[n]);
        }
    }
    return newArr;
}
console.log(fn(arr)); */


/* 
let arr = [1, 2, 5, 7, 3, 6, 4];
for (let i = 0; i < arr.length; i++) {
    for (let j = 0; j < arr.length - 1; j++) {
        if (arr[j] < arr[j + 1]) {
            let n = arr[j + 1];
            arr[j + 1] = arr[j];
            arr[j] = n;
        }
    }
}
console.log(arr); */
/* for (let i = 0; i < arr.length - 1; i++) {
    let min = i;
    for (let j = i + 1; j < arr.length; j++) {
        if(arr[j] < arr[min]) min = j;
    }

    let n = arr[i];
    arr[i] = arr[min];
    arr[min] = n;
}
console.log(arr); */

/* function randomColor(op = 1) {
    function rgb() {
        return Math.floor(Math.random() * 256)
    }
    return `rgba(${rgb()},${rgb()},${rgb()},${op})`;
}
console.log(randomColor(0.5)); */


/* let arr = ['a', 'b', 'a', 'b', 'b', 'c'];
let obj = {};
let res = arr.forEach(function (item) {
    obj[item] ? obj[item]++ : obj[item] = 1;
})
console.log(obj); */

/* function fn(time) {
    let time1 = new Date(time);
    let time2 = new Date();
    let time3 = time1.getTime() - time2.getTime();

    let day = time3 / (1000 * 60 * 60 * 24);
    day = Math.floor(day);

    let H = time3 - day * (1000 * 60 * 60 * 24);
    let hour = H / (1000 * 60 * 60);
    hour = Math.floor(hour);

    let M = H - hour * (1000 * 60 * 60);
    let min = M / (1000 * 60)
    min = Math.floor(min);

    let S = M - 1000 * 60 * min;
    let seconds = Math.floor(S / 1000);

    return `距离${time}还有${day}天${hour}时${min}分${seconds}秒`;
}
console.log(fn("2024-01-01")); */









